
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>03_数组扩展</title>
</head>
<body>
<button>测试1</button>
<br>
<button>测试2</button>
<br>
<button>测试3</button>
<br>

<!--
1. Array.from(v) : 将伪数组对象或可遍历对象转换为真数组
2. Array.of(v1, v2, v3) : 将一系列值转换成数组
3. find(function(value, index, arr){return true}) : 找出第一个满足条件返回true的元素
4. findIndex(function(value, index, arr){return true}) : 找出第一个满足条件返回true的元素下标
-->
<script type="text/javascript">
    // Array.from(v)
  let btns=document.getElementsByTagName('button');
  Array.from(btns).forEach(function (item,index) {
      console.log(item)
  })
  let arrayLike = {
      0: 'tom',
      1: '65',
      2: '男',
      3: ['jane','john','Mary'],
      'length': 4
  }
  let arr = Array.from(arrayLike)
  console.log(arr) // ['tom','65','男',['jane','john','Mary']]

  // Array.of(v1, v2, v3)
  let arr1=Array.of(1,2,3,4,5,'asd');
  console.log(arr1);

    // find findIndex
  let arr2=[32,123,41,1,2];
  let res2= arr2.find(function (item,index) {
      return item>120;
  })
  let res2index= arr2.findIndex(function (item,index) {
      return item>120;
  })
    console.log(res2,res2index);
</script>
</body>

</html>